import { ChainId, Token } from "@pancakeswap/sdk";

import icon1INCH from "@/assets/token/icon-1inch.svg";
import iconBUSD from "@/assets/token/icon-busd.svg";
import iconDAI from "@/assets/token/icon-dai.svg";
import iconFTM from "@/assets/token/icon-ftm.svg";
import iconLINK from "@/assets/token/icon-link.svg";
import iconMATIC from "@/assets/token/icon-matic.svg";
import iconSHIB from "@/assets/token/icon-shib.svg";
import iconUNI from "@/assets/token/icon-uni.svg";
import iconUSDC from "@/assets/token/icon-usdc.svg";
import iconUSDT from "@/assets/token/icon-usdt.svg";
import iconBNB from "@/assets/token/icon-bnb.svg";
import iconCAKE from "@/assets/token/icon-cake.svg";
import iconDOGE from "@/assets/token/icon-doge.svg";
import iconOOE from "@/assets/token/icon-ooe.svg";
import iconTSE from "@/assets/token/icon-tse.svg";

export const tokenList = [
  {
    code: "binancecoin",
    name: "Binance Coin",
    symbol: "BNB",
    icon: iconBNB,
    decimals: "18",
    address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE",
  },
  {
    code: "binance-usd",
    name: "Binance-Peg BUSD Token",
    symbol: "BUSD",
    icon: iconBUSD,
    decimals: "18",
    address: "0xe9e7cea3dedca5984780bafc599bd69add087d56",
  },
  {
    code: "tether",
    name: "Binance-Peg USD (T)",
    symbol: "USDT",
    icon: iconUSDT,
    decimals: "6",
    address: "0x55d398326f99059ff775485246999027b3197955",
  },
  {
    code: "tokenswap",
    name: "TokenSwap Token",
    symbol: "TSE",
    icon: iconTSE,
    decimals: "18",
    address: "0x4f878f1d43c8bc18984f278db7ca43e749c78801",
  },
  {
    code: "pancakeswap-token",
    name: "PancakeSwap Token",
    symbol: "CAKE",
    icon: iconCAKE,
    decimals: "18",
    address: "0x0e09fabb73bd3ade0a17ecc321fd13a19e81ce82",
  },
  {
    code: "binance-peg-dogecoin",
    name: "Binance-Peg Dogecoin",
    symbol: "DOGE",
    icon: iconDOGE,
    decimals: "18",
    address: "0xba2ae424d960c26247dd6c32edc70b295c744c43",
  },
  {
    code: "usd-coin",
    name: "USD Coin",
    symbol: "USDC",
    icon: iconUSDC,
    decimals: "6",
    address: "0x1dDcaa4Ed761428ae348BEfC6718BCb12e63bFaa",
  },
  {
    code: "dai",
    name: "Dai Stablecoin",
    symbol: "DAI",
    icon: iconDAI,
    decimals: "18",
    address: "0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3",
  },
  {
    code: "shiba-inu",
    name: "SHIBA INU",
    symbol: "SHIB",
    icon: iconSHIB,
    decimals: "18",
    address: "0x2859e4544C4bB03966803b044A93563Bd2D0DD4D",
  },
  {
    code: "uniswap",
    name: "Uniswap",
    symbol: "UNI",
    icon: iconUNI,
    decimals: 18,
    address: "0xbf5140a22578168fd562dccf235e5d43a02ce9b1",
  },
  {
    code: "openocean",
    name: "OpenOcean",
    symbol: "OOE",
    icon: iconOOE,
    decimals: "18",
    address: "0x9029FdFAe9A03135846381c7cE16595C3554e10A",
  },
  {
    code: "matic-network",
    name: "Matic Token",
    symbol: "MATIC",
    icon: iconMATIC,
    decimals: 18,
    address: "0xcc42724c6683b7e57334c4e856f4c9965ed682bd",
  },
  {
    code: "chainlink",
    name: "Chain Link",
    symbol: "LINK",
    icon: iconLINK,
    decimals: 18,
    address: "0xf8a0bf9cf54bb92f17374d9e9a321e6a111a51bd",
  },
  {
    code: "1inch",
    name: "1INCH Token",
    symbol: "1INCH",
    icon: icon1INCH,
    decimals: 18,
    address: "0x111111111117dc0aa78b770fa6a738034120c302",
  },
  {
    code: "fantom",
    name: "Fantom Token",
    symbol: "FTM",
    icon: iconFTM,
    decimals: 18,
    address: "0xad29abb318791d579433d831ed122afeaf29dcfe",
  },
].map((item) => {
  return {
    balance: 0,
    allowance: 0,
    ...item,
  };
});

export const getTokenBySymbol = (symbol) => {
  const list = tokenList.filter((item) => {
    return symbol === item.symbol;
  });
  if (!list || !list[0]) return null;

  const { code, name, icon, decimals, address } = list && list[0];
  const token = new Token(ChainId.MAINNET, address, decimals, symbol, name);
  token.code = code;
  token.icon = icon;
  return token;
};

export const getTokenByAddress = (address) => {
  const list = tokenList.filter((item) => {
    return address.toLowerCase() === item.address.toLowerCase();
  });
  if (!list || !list[0]) return null;

  const { code, name, icon, decimals, symbol } = list && list[0];
  const token = new Token(ChainId.MAINNET, address, decimals, symbol, name);
  token.code = code;
  token.icon = icon;
  return token;
};
